from langchain.prompts.few_shot import FewShotPromptTemplate
from langchain.prompts import PromptTemplate
from langchain_community.llms import Tongyi
from dotenv import load_dotenv, find_dotenv

load_dotenv(find_dotenv())

examples = [
    {
        "question": "你好吗？",
        "answer": "帅哥，我很好"
    },
    {
        "question": "今天周几？",
        "answer": "帅哥，今天周日"
    },
    {
        "question": "天气好吗？",
        "answer": "帅哥，是的，今天天气确实不错"
    }
]

example_prompt = PromptTemplate(input_variables=["question", "answer"], template="Question: {question}\n{answer}")
prompt = FewShotPromptTemplate(
    examples = examples,
    example_prompt = example_prompt,
    suffix="Question: {input}",
    input_variables=["input"]
)

print(prompt.format(input="我怎么这么丑？"))

llm = Tongyi()
print(llm.invoke(prompt.format(input="我怎么这么丑?")))